//
//  ParametersADSR.m
//  CocoaSynth
//
//  Created by Thomas Dupont on 22/02/10.
//  Copyright 2010 Apple Inc. All rights reserved.
//

#import "ParametersADSR.h"

#import "ModuleADSRViewController.h"
#import "ModuleADSRProtocol.h"

@implementation ParametersADSR

@synthesize module;
@synthesize attackSlider, decaySlider, sustainSlider, releaseSlider;
@synthesize attackText, decayText, sustainText, releaseText;

- (void)load
{
	
}

- (void)awakeFromNib
{
	[attackSlider setFloatValue:0.02];
	[self attackChange:nil];
	[decaySlider setFloatValue:0.2];
	[self decayChange:nil];
	[sustainSlider setFloatValue:0.5];
	[self sustainChange:nil];
	[releaseSlider setFloatValue:0.4];
	[self releaseChange:nil];
}

- (IBAction)attackChange:(id)sender
{
	[attackText setTitleWithMnemonic:[NSString stringWithFormat:@"%.f ms",([attackSlider floatValue] * 1000)]];
	[(id<ModuleADSRProtocol>)[module model] setAttack:[attackSlider floatValue]];
}

- (IBAction)decayChange:(id)sender
{
	[decayText setTitleWithMnemonic:[NSString stringWithFormat:@"%.f ms",([decaySlider floatValue] * 1000)]];
	[(id<ModuleADSRProtocol>)[module model] setDecay:[decaySlider floatValue]];
}

- (IBAction)sustainChange:(id)sender
{
	[sustainText setTitleWithMnemonic:[NSString stringWithFormat:@"%.1f",[sustainSlider floatValue]]];
	[(id<ModuleADSRProtocol>)[module model] setSustain:[sustainSlider floatValue]];
}

- (IBAction)releaseChange:(id)sender
{
	[releaseText setTitleWithMnemonic:[NSString stringWithFormat:@"%.f ms",([releaseSlider floatValue] * 1000)]];
	[(id<ModuleADSRProtocol>)[module model] setRelease:[releaseSlider floatValue]];
}


@end
